<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-4">
  <div class="opera-wrap">
    <a
      nz-button
      nzType="primary"
      routerLink="/aisi-recyc/love-send-idol-edit"
      [queryParams]="{type: 0}"
    >新增活动</a>
  </div>

  <div class="pagination-wrap-position p-t-15">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      nzTableLayout="fixed"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="100px">ID</th>
          <th nzAlign="center" nzWidth="120px">活动状态</th>
          <th nzAlign="center" nzWidth="120px">活动名称</th>
          <th nzAlign="center" nzWidth="200px">适用成色</th>
          <th nzAlign="center" nzWidth="200px" nzEllipsis>适用机型</th>
          <th nzAlign="center" nzWidth="170px">活动开始时间</th>
          <th nzAlign="center" nzWidth="170px">活动结束时间</th>
          <th nzAlign="center" nzWidth="170px">更新时间</th>
          <th nzAlign="center" nzWidth="250px" nzRight>操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- ID -->
          <td nzAlign="center">{{ data.id }}</td>
          <!-- 活动状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.state | loveRecoveryActstatus: 'color'}">
              {{ data.state | loveRecoveryActstatus: 'label' }}
            </span>
          </td>
          <!-- 活动名称 -->
          <td nzAlign="center">{{ data.name || '-' }}</td>
          <!-- 适用成色 -->
          <td nzAlign="center">{{ setDictText(conditionOptionsC, 'id', data.colourId) }}</td>
          <!-- 适用机型 -->
          <td
            nzAlign="center"
            nzEllipsis
            nz-popover
            [nzPopoverContent]="modelContentTemplate">
            <ng-template #modelContentTemplate>
              <p style="max-width: 620px;">
                {{ data.modelName || '-' }}
              </p>
            </ng-template>
            {{ data.modelName || '-' }}
          </td>
          <!-- 活动开始时间 -->
          <td nzAlign="center">{{ data.beginTime || '-' }}</td>
          <!-- 活动结束时间 -->
          <td nzAlign="center">{{ data.endTime || '-' }}</td>
          <!-- 更新时间 -->
          <td nzAlign="center">{{ data.updateTime || '-' }}</td>
          <!-- 操作 -->
          <td nzAlign="center" nzRight>
            <a
              *ngIf="![5].includes(data.state)"
              nz-button
              nzType="link"
              nzSize="small"
              routerLink="/aisi-recyc/love-send-idol-details"
              [queryParams]="{id: data.id}"
            >查看</a>

            <a
              *ngIf="[1, 2, 5].includes(data.state)"
              nz-button
              nzType="link"
              nzSize="small"
              routerLink="/aisi-recyc/love-send-idol-edit"
              [queryParams]="{type: 1, id: data.id}"
            >编辑</a>
            
            <a
              *ngIf="![5].includes(data.state)"
              style="color: #E6A23C;"
              nz-button
              nzType="link"
              nzSize="small"
              routerLink="/aisi-recyc/love-send-idol-edit"
              [queryParams]="{type: 2, id: data.id}"
            >复制</a>

            <a
              *ngIf="[1, 2].includes(data.state)"
              nz-button
              nzType="link"
              nzSize="small"
              nzDanger
              nz-popconfirm
              nzPopconfirmTitle="是否需要提前终止活动?"
              (nzOnConfirm)="overDeleteItem(data, 4)"
            >终止</a>

            <a
              *ngIf="[5].includes(data.state)"
              nz-button
              nzType="link"
              nzSize="small"
              nzDanger
              nz-popconfirm
              nzPopconfirmTitle="是否要删除?"
              (nzOnConfirm)="overDeleteItem(data, 6)"
            >删除</a>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>